package com.mjl.shops.activity;


import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;

import com.mjl.shops.R;
import com.mjl.shops.base.BaseActivity;
import com.mjl.shops.utils.CommUtils;
import com.mjl.shops.utils.StringUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ReplacePassActivity extends BaseActivity {

    @BindView(R.id.rep_input_phone_et)
    EditText phone_et;

    @BindView(R.id.rep_input_sms_code_et)
    EditText sms_code_et;

    @BindView(R.id.rep_input_pass_et)
    EditText pass_et;

    @BindView(R.id.rep_again_input_pass_et)
    EditText again_pass_et;

    @BindView(R.id.title_text_tv)
    TextView title_text_tv;

    @Override
    protected void setContentViewBefore() {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    }

    @Override
    protected int getViews() {
        return R.layout.activity_replace_pass;
    }

    @Override
    protected void setViews() {
        ButterKnife.bind(this);
        title_text_tv.setText("更改密码");
    }

    @Override
    protected void setDate() {

    }

    @Override
    protected String getStateColor() {
        return CommUtils.color_05000000;
    }

    @Override
    protected int getStetaBackgroundStyle() {
        return 1;
    }

    @OnClick({R.id.icon_back, R.id.rep_pass_tv, R.id.get_sms_code_tv})
    public void OnClick(View view) {
        switch (view.getId()) {
            case R.id.icon_back:
                finish();
                break;
            case R.id.rep_pass_tv:
                String phone = phone_et.getText().toString().trim();
                String sms_code = sms_code_et.getText().toString().trim();
                String pass = pass_et.getText().toString().trim();
                String againPass = again_pass_et.getText().toString().trim();
                if (!StringUtils.strEmpty(phone) && !StringUtils.isPhone(phone)) {
                    CommUtils.setToast("请输入正确的手机号");
                    return;
                }

                if (!StringUtils.strEmpty(sms_code)) {
                    CommUtils.setToast("请输入短信验证码");
                    return;
                }

                if (!StringUtils.strEmpty(pass)) {
                    CommUtils.setToast("请输入密码");
                    return;
                }

                if (pass.length() < 6 || pass.length() > 20) {
                    CommUtils.setToast("密码长度错误");
                    return;
                }

                if (!StringUtils.strEmpty(againPass) && !againPass.equals(pass) && againPass.length() != pass.length()) {
                    CommUtils.setToast("两次输入密码不一致");
                    return;
                }
                CommUtils.setToast("修改密码敬请期待！");
                break;
            case R.id.get_sms_code_tv:
                CommUtils.setToast("获取验证码敬请期待！");
                break;
            default:
                break;
        }

    }

    public static void StartIntent(Context contexts) {
        Intent intent = new Intent(contexts, ReplacePassActivity.class);
        contexts.startActivity(intent);
    }
}
